package me.hl.timer;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * author: planck
 * createTime: 2016/9/19.
 */
public class TimerTest {
    private static final Logger logger = LoggerFactory.getLogger(TimerTest.class);

    @Test
    public void timeTest() {

        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                logger.info("start date is {}", new Date());
            }
        };
        Timer timer = new Timer();
        timer.schedule(timerTask, 10000);

        logger.info("main over {}", new Date());

        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
